package br.com.fogas.webservice.repository.soap;

import android.content.Context;
import br.com.fogas.utils.exception.ParseXmlException;
import br.com.fogas.webservice.exception.ERaiseWebServiceException;
import br.com.fogas.webservice.exception.RespostaWebServiceException;
import br.com.fogas.webservice.exception.SemConexaoInternetException;
import br.com.fogas.webservice.exception.ServidorForaException;
import br.com.fogas.webservice.exception.TempoEsperaRespostaException;
import br.com.fogas.webservice.exception.WebServiceException;
import br.com.fogas.webservice.parser.notafiscal.NotaFiscalEnvelope;
import br.com.fogas.webservice.parser.notafiscal.NotaFiscalRequest;
import br.com.fogas.webservice.parser.notafiscal.NotaFiscalResponse;
import br.com.fogas.webservice.repository.IRepositoryHandler;
import br.com.fogas.webservice.soap.impl.NotaFiscalSOAP;

public class NotaFiscalRepository implements IRepositoryHandler<NotaFiscalResponse> {
	
	private Context context;
	private NotaFiscalRequest request;

	public NotaFiscalRepository(Context  context, NotaFiscalRequest request) {
		this.context = context;
		this.request = request;
	}

	@Override
	public NotaFiscalResponse getResponse() throws SemConexaoInternetException,
			ParseXmlException, TempoEsperaRespostaException,
			ServidorForaException, RespostaWebServiceException,
			WebServiceException, ERaiseWebServiceException {
		
		NotaFiscalEnvelope envelope = new NotaFiscalEnvelope();
		envelope.body.request = request;
		
		NotaFiscalSOAP soap = new NotaFiscalSOAP(context, envelope);
		return soap.getResponse();
	}
}
